<template>
  <div>
    <el-breadcrumb separator="/">
    <el-breadcrumb-item :to="{path:'/home'}">首页</el-breadcrumb-item>
  <!-- <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item> -->
  <el-breadcrumb-item><a href="/">用户管理</a></el-breadcrumb-item>
  <el-breadcrumb-item>用户列表</el-breadcrumb-item>
</el-breadcrumb>
<el-card class="box-card">

  <el-row :gutter="20">
  <el-col :span="7"><div class="grid-content bg-purple"><el-input placeholder="请输入内容" class="input-with-select">
    <el-button slot="append" icon="el-icon-search"></el-button>
  </el-input></div></el-col>
  <el-col :span="3"><div class="grid-content bg-purple"><el-button type="primary">添加</el-button></div></el-col>
</el-row>
<el-table
      :data="userListInfo"
      style="width: 100%">
      <el-table-column
        type="index" label="#">
      </el-table-column>
      <el-table-column
        prop="username" label="姓名">
      </el-table-column>
      <el-table-column
        prop="email" label="邮箱">
      </el-table-column>
      <el-table-column
        prop="mobile" label="电话">
      </el-table-column>
      <el-table-column
        prop="role_name" label="角色">
      </el-table-column>
      <el-table-column
        prop="mg_state" label="状态" width="180px">
        <template slot-scope="scope">
          <el-switch
         v-model="scope.row.mg_state"
         active-color="#13ce66"
         inactive-color="#ff4949">
</el-switch>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="180px">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" icon="el-icon-edit"></el-button>
          <el-button size="mini" type="danger" icon="el-icon-delete"></el-button>
          <el-button size="mini" type="warning" icon="el-icon-setting"></el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page=queryListInfo.pagenum
      :page-sizes="[1, 2, 3, 4]"
      :page-size=queryListInfo.pagesize
      layout="total, sizes, prev, pager, next, jumper"
      :total="4">
    </el-pagination>
</el-card>
  </div>
</template>
<script>
export default {
  data () {
    return {
      queryListInfo: {
        query: '',
        pagenum: 1,
        pagesize: 3
      },
      userListInfo: []

    }
  },
  created () {
    this.getUserList()
  },
  methods: {
    async getUserList () {
      const { data: res } = await this.$http.get('users', { params: this.queryListInfo })
      console.log(res)
      if (res.meta.status !== 200) return this.$message.error(res.meta.msg)
      this.userListInfo = res.data.users
    },
    handleSizeChange (newSize) {
      this.queryListInfo.pagesize = newSize
      this.getUserList()
    },
    handleCurrentChange (newCurrent) {
      this.queryListInfo.pagenum = newCurrent
      this.getUserList()
    }

  }
}
</script>
<style lang="less" scoped>
</style>
